home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / r / real_3d / real3dv3.3b.dms / real3dv3.3b.adf / GUI.LZH / GUI / surface.gui < prev   
Text File  |  1995-05-04  |  6KB  |  247 lines

  1.  
  2. ( Interface for creating 'SURFACE' animation method applications
  3. (
  4.  
  5. ?& SURFACE_GUI NOT ?IF
  6. 1 CONSTANT SURFACE_GUI
  7.  
  8. "ui.rpl" LOAD
  9. "locks.rpl" LOAD
  10.  
  11. ( Global variables
  12.  
  13. VARIABLE asuWindow
  14. VARIABLE asuTarget
  15. VARIABLE asuGravity
  16. VARIABLE asuGround
  17. VARIABLE asuApply
  18. VARIABLE asuHelp
  19. VARIABLE asuCancel
  20. VARIABLE isuFlags
  21. VARIABLE asuText
  22. VARIABLE asuTxtTarget
  23. VARIABLE asuTxtGravity
  24. VARIABLE asuTxtGround
  25. VARIABLE isuStampIndex
  26.  
  27. ( these variables points to selected objects
  28. 400 STRING ssuTarget
  29. 400 STRING ssuGravity
  30. 400 STRING ssuGround
  31.  
  32. ( flags for disabling buttons
  33. 1 CONSTANT fsuTarget
  34. 2 CONSTANT fsuGravity
  35. 4 CONSTANT fsuGround
  36.  
  37. fsuTarget fsuGravity fsuGround BOR BOR CONSTANT fsuAll
  38.  
  39. 1 CONSTANT TRUE
  40. 0 CONSTANT FALSE
  41. 0 CONSTANT NULL
  42.  
  43. ( this enables apply when isuFlags is equal to fsuAll
  44.  
  45. : suEnableApply
  46.     isuFlags FETCH fsuAll =
  47.     IF
  48.         UI_Done "Select friction points and click Apply" UITX_Text asuText FETCH UI_SETATTRS
  49.         UI_Done FALSE UI_Disabled asuApply FETCH UI_SETATTRS
  50.     ENDIF
  51. ;
  52.  
  53. ( saves the name of selected object to given string buffer
  54.  
  55. : suStoreSelected 
  56.     PARAM 
  57.         VARIABLE ssuName 
  58.     ENDPARAM
  59.  
  60.     iLOCK_SHARED O_LOCK
  61.     O_GETSEL DUP IF
  62.         ssuName FETCH O_MAKENAME
  63.         DROP
  64.         1
  65.     ENDIF
  66.     iLOCK_REMOVE O_LOCK
  67. ;
  68.  
  69. ( Callbacks for Gadgets
  70.  
  71. : sucbTarget
  72.     ssuTarget suStoreSelected 
  73.     IF
  74.         UI_Done TRUE UI_Disabled asuTarget FETCH UI_SETATTRS
  75.         UI_Done ssuTarget UITX_Text asuTxtTarget FETCH UI_SETATTRS
  76.         UI_Done "Target defined" UITX_Text asuText FETCH UI_SETATTRS
  77.         isuFlags FETCH fsuTarget BOR isuFlags STORE
  78.         suEnableApply
  79.     ELSE
  80.         UI_Done "No target object selected" UITX_Text asuText FETCH UI_SETATTRS
  81.     ENDIF
  82. ;
  83.  
  84. : sucbGravity
  85.     ssuGravity suStoreSelected 
  86.     IF
  87.         UI_Done TRUE UI_Disabled asuGravity FETCH UI_SETATTRS
  88.         UI_Done ssuGravity UITX_Text asuTxtGravity FETCH UI_SETATTRS
  89.         UI_Done "Gravity defined" UITX_Text asuText FETCH UI_SETATTRS
  90.         isuFlags FETCH fsuGravity BOR isuFlags STORE
  91.         suEnableApply
  92.     ELSE
  93.         UI_Done "No gravity object selected" UITX_Text asuText FETCH UI_SETATTRS
  94.     ENDIF
  95. ;
  96.  
  97. : sucbGround
  98.     ssuGround suStoreSelected 
  99.     IF
  100.         UI_Done TRUE UI_Disabled asuGround FETCH UI_SETATTRS
  101.         isuFlags FETCH fsuGround BOR isuFlags STORE
  102.         UI_Done ssuGround UITX_Text asuTxtGround FETCH UI_SETATTRS
  103.         UI_Done "Ground defined" UITX_Text asuText FETCH UI_SETATTRS
  104.         suEnableApply
  105.     ELSE
  106.         UI_Done "No ground object selected" UITX_Text asuText FETCH UI_SETATTRS
  107.     ENDIF
  108. ;
  109.  
  110. : sucbHelp
  111.     "emacs r3d3:gui/surface.gui" SYSTEM
  112. ;
  113.  
  114. : suCreateLink
  115.     PARAM 
  116.         VARIABLE aObject
  117.     ENDPARAM
  118.     100 STRING sStamp
  119.  
  120.     ( build up date stamp used for linking objects
  121.     isuStampIndex FETCH DUP 1 + isuStampIndex STORE
  122.     DATETIME "%d %d:%d:%d %d-%d-%d" sStamp SPRINTF
  123.  
  124.     ( create a link object with the time stamp
  125.     "link" 0 "CEND" sStamp "SIDE" C_LINK DROP
  126.  
  127.     ( add time stamp to target object
  128.     aObject FETCH "CEND" sStamp "SIDE" O_CREATAG DROP
  129. ;
  130.  
  131. : suCreateMethod 
  132.     400 STRING sTmpName
  133.  
  134.     iLOCK_EXCL O_LOCK
  135.  
  136.     ssuTarget O_FIND O_GETPAR O_CURRENT DROP
  137.  
  138.     ( create the actual surface method
  139.     2 "DRAG" 0 "CEND" "DRAG" "SMTH" C_LEVEL O_CURRENT DROP
  140.  
  141.     ( push currently selected objects on the stack
  142.     O_GETSEL
  143.  
  144.     ( gravity is the first parameter object
  145.     0 ssuGravity O_FIND M_CUT 
  146.     O_GETCURR 0 M_PASTE
  147.  
  148.     ( ground is the second param object
  149.     0 ssuGround O_FIND M_CUT 
  150.     O_GETCURR 0 M_PASTE
  151.  
  152.     ( third parameter object is a level consisting of links to friction points
  153.     2 "links" 0 "CEND" C_LEVEL O_CURRENT DROP
  154.  
  155.     ( scan through selected objects and create links
  156.     BEGIN 
  157.     DUP 
  158.     WHILE
  159.         suCreateLink
  160.     REPEAT
  161.     DROP
  162.  
  163.     iLOCK_REMOVE O_LOCK
  164. ;
  165.  
  166. : sucbApply
  167.  
  168.     ( enable other buttons
  169.     UI_Done FALSE UI_Disabled asuTarget  FETCH UI_SETATTRS
  170.     UI_Done FALSE UI_Disabled asuGravity FETCH UI_SETATTRS
  171.     UI_Done FALSE UI_Disabled asuGround  FETCH UI_SETATTRS
  172.  
  173.     ( clear object names
  174.     UI_Done "" UITX_Text asuTxtTarget FETCH UI_SETATTRS
  175.     UI_Done "" UITX_Text asuTxtGravity FETCH UI_SETATTRS
  176.     UI_Done "" UITX_Text asuTxtGround FETCH UI_SETATTRS
  177.  
  178.     ( disable apply
  179.     UI_Done TRUE UI_Disabled asuApply FETCH UI_SETATTRS
  180.  
  181.     ( clear flags
  182.     0 isuFlags STORE
  183.  
  184.     ( do the actual job
  185.     UI_Done "Creating surface method ..." UITX_Text asuText FETCH UI_SETATTRS
  186.  
  187.     suCreateMethod
  188.  
  189.     UI_Done "Done" UITX_Text asuText FETCH UI_SETATTRS
  190. ;
  191.  
  192. : sucbCancel
  193.     asuWindow FETCH UI_DELETE
  194.     NULL asuWindow STORE
  195. ;
  196.  
  197. : sucbWindow 
  198.     PARAM
  199.         VARIABLE iMouseY
  200.         VARIABLE iMouseX
  201.         VARIABLE iEvent
  202.     ENDPARAM
  203.  
  204.     iEvent FETCH UIWM_Close = 
  205.     IF
  206.         asuWindow FETCH UI_DELETE
  207.         NULL asuWindow STORE
  208.     ENDIF
  209. ;
  210.  
  211. ?ENDIF 
  212.  
  213. asuWindow FETCH 
  214. ?IF
  215.     "Alright" "Window is already open" GET_KEY DROP
  216. ?ELSE
  217.     ( create a window 
  218.     UI_Done & sucbWindow 0 0 520 120 "Create Surface Animation Object" UI_WINDOW asuWindow STORE
  219.  
  220.     ( create text gadgets
  221.     UI_Done TRUE UITX_Border asuWindow FETCH 0 100 20 300 12 "Target"  UI_TEXT asuTxtTarget STORE
  222.     UI_Done TRUE UITX_Border asuWindow FETCH 0 100 35 300 12 "Gravity" UI_TEXT asuTxtGravity STORE
  223.     UI_Done TRUE UITX_Border asuWindow FETCH 0 100 50 300 12 "Ground"  UI_TEXT asuTxtGround STORE
  224.  
  225.     ( create buttons
  226.     UI_Done asuWindow FETCH & sucbTarget  400 20 100 12 "Target"  UI_BUTTON asuTarget STORE
  227.     UI_Done asuWindow FETCH & sucbGravity 400 35 100 12 "Gravity" UI_BUTTON asuGravity STORE
  228.     UI_Done asuWindow FETCH & sucbGround  400 50 100 12 "Ground"  UI_BUTTON asuGround STORE
  229.  
  230.     UI_Done asuWindow FETCH & sucbApply   5 100 100 12 "Apply"    UI_BUTTON asuApply STORE
  231.     UI_Done asuWindow FETCH & sucbHelp    200 100 100 12 "Help"   UI_BUTTON asuHelp STORE
  232.     UI_Done asuWindow FETCH & sucbCancel  400 100 100 12 "Cancel" UI_BUTTON asuCancel STORE
  233.  
  234.     UI_Done 
  235.     TRUE UITX_Border 
  236.     "Use select window and buttons above to select four objects" UITX_Text
  237.     asuWindow FETCH 0 100 80 400 12 "Status" UI_TEXT asuText STORE
  238.  
  239.     ( realize gadgets
  240.     asuWindow FETCH UI_REALIZE
  241.  
  242.     ( disable apply 
  243.     UI_Done TRUE UI_Disabled asuApply FETCH UI_SETATTRS
  244.  
  245. ?ENDIF ( SURFACE_GUI
  246.